{% stylesheet %}
.block_collection_tab .block_collection_product_tab_title {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    margin-top: calc(var(--general_layout_spacing) * 0.75);
}
.block_collection_tab .block_collection_product_tab_title::-webkit-scrollbar-track-piece{
    background-color:#f8f8f8; 
} 
.block_collection_tab .block_collection_product_tab_title::-webkit-scrollbar{
    width:0; height:0; 
} 
.block_collection_tab .block_collection_product_tab_title::-webkit-scrollbar-thumb{ 
    background-color:#dddddd; 
    background-clip:padding-box; 
    min-height:28px; 
} 
.block_collection_tab .block_collection_product_tab_title::-webkit-scrollbar-thumb:hover{ 
    background-color:#bbb; 
}
.block_collection_tab .block_collection_product_tab_title a {
    display: block;
    height: 50px;
    line-height: 50px;
    margin: 0 20px;
    position: relative;
    transition: all 0.3s;
    color: #666;
    font-size: calc(var(--title_font_size) * 0.75);
    font-family: var(--title_font_family);
    font-style: var(--title_font_style);
    font-weight: var(--title_font_weigth);
    letter-spacing: var(--title_letter_spacing);
}



.block_collection_tab .block_collection_product_tab_title a:before {
    content: '';
    width: 100%;
    height: 2px;
    background:var(--title_color);
    position: absolute;
    left: 0;
    bottom: 0;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.block_collection_tab .block_collection_product_tab_title a.on {
    color: var(--title_color);
}

.block_collection_tab .block_collection_product_tab_title a.on:before {
    opacity: 1;
    visibility: visible;
}

.block_collection_tab .block_collection_product_tab_items_content {
    display: none;
}

.block_collection_tab .block_collection_product_tab_items_content.on {
    display: block;
}



.block_collection_tab .block_collection_product_tab_items_content ul {
    display: grid;
    row-gap: 30px;
    column-gap: 30px;
    grid-template-columns: repeat(4, calc(25% - 22.5px));
}

.block_collection_tab .block_collection_product_tab_items_content li {
    width: 100%;
    list-style-type: none;
    line-height: 1.4;
    text-align: center;
}

.block_collection_tab .block_collection_product_tab_items_content .product_pic {
    width: 100%;
    margin-bottom: 26px;
    position: relative;
}

.block_collection_tab .block_collection_product_tab_items_content .soldout {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 30px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 50px;
    background: rgba(0, 0, 0, .3);
    color: #fff;
    font-size: 14px;
}

.block_collection_tab .block_collection_product_tab_items_content .product_pic .product_img {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* width: 100%; */
}

.block_collection_tab .block_collection_product_tab_items_content .product_pic img {
    max-width: 100%;
}

.block_collection_tab .block_collection_product_tab_items_content .block_product_name {
    margin-bottom: 4px;
    line-height: 1.5;
}



.block_collection_tab .block_collection_product_tab_items_content .product_price {
    font-weight: bold;
}

.block_collection_tab .block_collection_product_tab_items_content .product_oldprice {
    color: #888;
    text-decoration: line-through;
    margin-left: 5px;
    display: inline-block;
    font-weight: normal;
}


.block_collection_tab .collection_product_pc_3 ul {
    grid-template-columns: repeat(3, calc(33.3333% - 20px));
}

.block_collection_tab .collection_product_pc_4 ul {
    grid-template-columns: repeat(4, calc(25% - 22.5px));
}

.block_collection_tab .collection_product_pc_5 ul {
    grid-template-columns: repeat(5, calc(20% - 24px));
}

.block_collection_tab .block_collection_product_more {
    margin-top: calc(var(--general_layout_spacing) * 0.5);
    text-align: center;
}

.block_collection_tab .block_collection_product_more a {
    margin: 0;
}
.block_collection_tab  .product_name {
    margin-bottom: 10px;
    line-height: 1.5;
    font-size: var(--product_font_size);
    color: var(--title_color);
}
.block_collection_tab .product_name  a{
  color: var(--title_color)
}
@media (max-width: 768px) {
    .block_collection_tab .block_collection_product_tab_title a {
        text-align: center;
        display: inline-block;
        font-size: 16px;
        white-space: nowrap;
    }
    .block_collection_tab .block_collection_product_tab_items_content ul{
        grid-template-columns: repeat(3, calc(33.33333% - 20px));
    }
}
@media (max-width: 767px) {
    .block_collection_tab .block_collection_product_tab_title{
        margin-top: calc(var(--general_layout_spacing) * 0.5);
        display: block;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        text-align: center;

    }

    .block_collection_tab .block_collection_product_tab_items_content ul {
        grid-row-gap: 18px;
        grid-column-gap: 15px;
        grid-template-columns: repeat(2, calc(50% - 7.5px));
    }

    .block_collection_tab .collection_product_wap_1 ul {
        display: block;
    }

    .block_collection_tab .collection_product_wap_1 ul li {
        list-style-type: none;
        margin-bottom: 30px;
    }
    .block_collection_tab .block_collection_product_tab_items_content .product_pic{
        margin-bottom: 18px;
    }
}

{% comment %} @media (max-width: 767px) {
    .block_collection_tab .block_collection_product .product_pic{
        margin-bottom: 20px !important;
    }
    .block_collection_tab .discount_tag.label_style_1,
    .block_collection_tab .discount_tag.label_style_2,
    .block_collection_tab .discount_tag.label_style_3,
    .block_collection_tab .discount_tag.label_style_4{
        transform: scale(0.8) translate(20%,-20%);
    }
} {% endcomment %}
{% endstylesheet %}
{% assign block_id = block_id | default : section.block_id %}
<div class="block_collection_tab" id="block_collection_tab_{{block_id}}"> 
    <div class="{% if section.settings.is_fill %}full_container_wrapper{% else %}container_wrapper{% endif %}">
      {% assign collection_ids = section.blocks | get_array_values: "collection" | get_array_values: "id" | join: "," %}
      {% get_collections ids={collection_ids} limit=100 %}
        <div class="block_title">
            {% if section.settings.title != '' %}<h2>{{ section.settings.title }}</h2>{% endif %}
            {% if section.settings.detail != '' %}<div class="block_detail">{{ section.settings.detail }}</div>{% endif %}
             {% if collection_ids %}
            <div class="block_collection_product_tab_title">
              {% for block in section.blocks %}
                {% assign id = block.collection.id %}
                {% if collections[id].size > 1 %}
                  <a href="javascript:void(0);">{{ section.blocks[forloop.index0].title | default:section.blocks[forloop.index0].collection.title }}</a>
                {% else %}
                  <a href="javascript:;">title</a>
                {% endif %}
              {% endfor %}
            </div>
            {% else %}
            <div class="block_collection_product_tab_title">
                <a href="{% if section.settings.switch == '1' %}javascript:void(0){% else %}/collections/{{ collection.handle }}{% endif %}">TAB</a>
            </div>
            {% endif %}
        </div>
        
        {% if collection_ids %}
        <div class="block_collection_product_tab_items collection_product_pc_{{ section.settings.pc_number }} collection_product_wap_{{ section.settings.wap_number }}">
            {% for block in section.blocks %}
                {% assign id = block.collection.id %}
                {% if collections[id].size > 1 %}
                  {% assign collection = collections[id] %}

            <div class="block_collection_product_tab_items_content">
                <ul >
                    {% get_products collection_id = { collection.id } limit = { section.settings.product_number } %}
                    {% for product in products %}
                    {% include 'collection_product', collection_handle:collection.handle  %}
                    {% endfor %}
                   
                </ul>

                {% if section.settings.more_text != ""%}
                <div class="block_collection_product_more"><a class="secondary_btn" href="/collections/{{ collection.handle }}">{{ section.settings.more_text }}</a></div>
                {% endif %}
            </div>
             {% else %}
                <div class="block_collection_product_tab_items_content">
                <ul>
                    {% for i in (1..section.settings.pc_number) %}
                    <li>
                        <div class="product_pic">
                            <a href="javascript:;"><img src="{{ 'empty.png' | public_asset_abs_url }}"></a>
                            <div class="discount_tag {{ theme_config.global.discount_label_style }}"><div class="discount_tag_graphics"></div><div class="discount_tag_name">88% <span>OFF</span></div></div>
                        </div>
                        <div class="product_name">
                            <a href="javascript:;">title</a>
                        </div>
                        <div class="product_price general_buying-color">$88.00<span class="product_oldprice general_original-color">$88.00</span></div>
                    </li>
                    {% endfor %}
                </ul>
                </div>
                 
                {% endif %}
            {% endfor %}
            
        </div>
        {% else %}
        <div class="block_collection_product_tab_items collection_product_pc_{{ section.settings.pc_number }} collection_product_wap_{{ section.settings.wap_number }}">
            <div class="block_collection_product_tab_items_content">
                <ul>
                    {% for i in (1..section.settings.pc_number) %}
                    <li>
                        <div class="product_pic">
                            <a href="javascript:;"><img src="{{ 'empty.png' | public_asset_abs_url }}"></a>
                            <div class="discount_tag {{ theme_config.global.discount_label_style }}"><div class="discount_tag_graphics"></div><div class="discount_tag_name">88% <span>OFF</span></div></div>
                        </div>
                        <div class="product_name">
                            <a href="javascript:;">title</a>
                        </div>
                        <div class="product_price general_buying-color">$88.00<span class="product_oldprice general_original-color">$88.00</span></div>
                    </li>
                    {% endfor %}
                </ul>
                {% if section.settings.more_text != ""%}
                <div class="block_collection_product_more"><a class="secondary_btn">{{ section.settings.more_text }}</a></div>
                {% endif %}
            </div>
        </div>
        {% endif %}
    </div>
</div>
<script type="text/javascript">
    console.log({{collections|json}})
    $(function(){
        var switch_{{block_id}} = {{ section.settings.switch }};
        var blockTab_{{block_id}} = $('#block_collection_tab_{{block_id}}');
        blockTab_{{block_id}}.find('.block_collection_product_tab_title').children('a').first().addClass('on');
        blockTab_{{block_id}}.find('.block_collection_product_tab_items_content').first().addClass('on');
        if(switch_{{block_id}} == '1'){
            blockTab_{{block_id}}.find('.block_collection_product_tab_title').children('a').click(function(){
                var _index = $(this).index();
                $(this).addClass('on').siblings('a').removeClass('on');
                blockTab_{{block_id}}.find('.block_collection_product_tab_items_content').eq(_index).show().siblings().hide();
                productSize(blockTab_{{block_id}}.find('.block_collection_product_tab_items_content').eq(_index).find(".product_img"));
            })
        }else{
            blockTab_{{block_id}}.find('.block_collection_product_tab_title').children('a').hover(function(){
                var _index = $(this).index();
                $(this).addClass('on').siblings('a').removeClass('on');
                blockTab_{{block_id}}.find('.block_collection_product_tab_items_content').eq(_index).show().siblings().hide();
                productSize(blockTab_{{block_id}}.find('.block_collection_product_tab_items_content').eq(_index).find(".product_img"));


            })
        }
        
    })
</script>

{% schema %}
{
  "tag": "",
  "class": "block_collection_tab",
  "is_global": false,
  "name": {
    "zh_CN": "商品选项卡"
  },
  "max_blocks": "20",
  "settings": [
    {
      "type": "card_header",
      "label": {
        "zh_CN": "设置"
      }
    },
    {
      "type": "card_input",
      "label": {
        "zh_CN": "标题"
      },
      "id": "title",
      "default": "New Arrivals"
    },
    {
      "type": "card_text_editor",
      "label": {
        "zh_CN": "简短描述"
      },
      "id": "detail",
      "default": "bottom_center"
    },
    {
      "type": "card_switch",
      "label": {
        "zh_CN": "宽度铺满"
      },
      "id": "is_fill",
      "default": "0"
    },
    {
      "type": "card_input",
      "label": {
        "zh_CN": "产品总数量"
      },
      "id": "product_number",
      "default": "8"
    },
    {
      "type": "card_slider",
      "label": {
        "zh_CN": "PC每排数量"
      },
      "id": "pc_number",
      "max": "5",
      "min": "3",
      "default": "4"
    },
    {
      "type": "card_slider",
      "label": {
        "zh_CN": "移动端每排数量"
      },
      "id": "wap_number",
      "max": "2",
      "min": "1",
      "default": "2"
    },
    {
      "type": "card_select",
      "label": {
        "zh_CN": "专辑切换方式"
      },
      "id": "switch",
      "option": [
        {
          "label": {
            "zh_CN": "鼠标点击"
          },
          "value": "1"
        },
        {
          "label": {
            "zh_CN": "鼠标移动"
          },
          "value": "2"
        }
      ],
      "default": "2"
    },
    {
      "type": "card_input",
      "label": {
        "zh_CN": "查看更多文案"
      },
      "id": "more_text"
    }
  ],
  "blocks": [
    {
      "name": {
        "zh_CN": "选择专辑"
      },
      "type": "collection-item",
      "settings": [
        {
          "type": "card_collection",
          "label": {
            "zh_CN": "选择专辑"
          },
          "default": {
            "id": "",
            "title": ""
          },
          "id": "collection"
        },
        {
          "type": "card_input",
          "label": {
            "zh_CN": "标题"
          },
          "default": "",
          "id": "title"
        }
      ]
    }
  ],
  "default": {
    "settings": {
      "title": "",
      "detail": "",
      "is_fill": "0",
      "product_number": "8",
      "pc_number": "4",
      "wap_number": "2",
      "switch": "2",
      "more_text": "View More"
    },
    "blocks": [
      {
        "collection": {
          "id": "",
          "title": ""
        },
        "title":"",
        "block_type": "collection-item"
      }
    ]
  }
}
{% endschema %}